package com.rmxx.fruit.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.company.android.fruit.R;
import com.kwan.xframe.mvp.presenter.BasePresenter;
import com.kwan.xframe.mvp.view.activity.BaseCommonRecycleActivity;
import com.rmxx.fruit.bean.Product;

import java.util.ArrayList;
import java.util.List;

public class ShopActivity extends BaseCommonRecycleActivity {

	protected List<Product> mProducts = new ArrayList<>();

	@Override
	protected BasePresenter getBasePresenter() {
		return null;
	}

	@Override
	protected RecyclerView.ItemDecoration getItemDecoration() {
		return null;
	}

	protected BaseQuickAdapter<Product, BaseViewHolder> mAdapter;

	@Override
	protected BaseQuickAdapter getAdapter() {

		Product product = new Product();
		product.setRicon(R.mipmap.product1_03);
		product.setName("澳洲牛腱子1kg进口牛肉");
		product.setDesc("无污染基地牧草饲养来自于大自然的…");
		product.setPrice(89.00f);
		mProducts.add(product);

		product = new Product();
		product.setRicon(R.mipmap.product2_02);
		product.setName("佳沛金奇异果");
		product.setDesc("在乎生活中的每件小事");
		product.setPrice(148.00f);
		mProducts.add(product);

		product = new Product();
		product.setRicon(R.mipmap.product2_03);
		product.setName("新鲜小土豆10斤农家自种蔬菜");
		product.setDesc("自然成熟 软如可口 大小均匀");
		product.setPrice(19.88f);
		mProducts.add(product);

		product = new Product();
		product.setRicon(R.mipmap.product2_04);
		product.setName("麻辣小龙虾香辣味鲜活现做");
		product.setDesc("个大体肥 鲜美入味 肉质Q谈");
		product.setPrice(69.88f);
		mProducts.add(product);

		mAdapter = new BaseQuickAdapter<Product, BaseViewHolder>(R.layout.list_item_shop_product, mProducts) {
			@Override
			protected void convert(BaseViewHolder helper, Product item) {
				helper.setImageResource(R.id.iv_icon, item.getRicon());
				helper.setText(R.id.tv_name,item.getName());
				helper.setText(R.id.tv_price,"¥"+item.getPrice());
				helper.setText(R.id.tv_desc,item.getDesc());
			}
		};
		return mAdapter;
	}

	@Override
	protected void initViewSetting() {
		super.initViewSetting();

		findViewById(R.id.v_back).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	@Override
	protected void initData() {
	}

	@Override
	protected RecyclerView.LayoutManager getLayoutManager() {
		return new LinearLayoutManager(this);
	}

	@Override
	protected String getTitleTxt() {
		return null;
	}

	@Override
	public String getPageName() {
		return null;
	}

	@Override
	protected int getTopViewId() {
		return R.layout.layout_shop_title;
	}
}
